package log;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class LogFile {

	private static final File LOG_FOLDER = new File("C:/Temp/Log/MP3Watchdog");
	private static BufferedWriter br;

	static {
		LOG_FOLDER.mkdirs();
		File logFile = new File(LOG_FOLDER, "MP3Watchdog.log");

		if (!logFile.exists()) {
			try {
				logFile.createNewFile();
			} catch (IOException e) {
				e.printStackTrace();
			}
		} else {
			logFile.delete();
		}

		try {
			br = new BufferedWriter(new FileWriter(logFile));
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	public static void logln(String message) {
		try {
			br.append(message + "\r\n");
			br.flush();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
